#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2023/4/4 14:28
# @Author : 闫峰
# @File    : sycitemid.py
from third_services.shopee.shop.shop import Interface_shop
from utils.mysqlUtils.db_pool import Database

db = Database("test_jdw_database")
Is = Interface_shop()
sql1 = """	SELECT `status` FROM t_shopee_listing WHERE item_id=%s;"""


class TestStcItemid:

    def test_syc_itemid(self):
        offset = 0
        count = 0

        while True:
            offset += 100
            res1 = Interface_shop().api_v2_product_get_item_list(13530, offset)
            if res1['response']["has_next_page"]:
                itemids = res1["response"]["item"]
                for item in itemids:
                    count += 1

                    res2 = db.fetch_all(sql1, (int(item['item_id']),))
                    if res2:
                        pass
                    else:
                        print(f"{item}在本地数据库不存在")
            else:
                break
        print(f"验证数据{count}个")


if __name__ == '__main__':
    TestStcItemid().test_syc_itemid()
